import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
 * This is a white blood cell. This kind of cell has the job to catch 
 * bacteria and remove them from the blood.
 * 
 * @author Michael Kölling
 * @version 0.1
 */
public class WhiteCell extends Actor
{
    
    private int getscore=0;   
    /**
     * Act: move up and down when cursor keys are pressed.
     */
    public void act() 
    {
        checkKeyPress();
        findAndEat();
    }
    
    /**
     * Check whether a keyboard key has been pressed and react if it has.
     */
    public void findAndEat(){
        if(isTouching(Bacteria.class)){
           Greenfoot.playSound("slurp.wav");
           removeTouching(Bacteria.class);
           getscore+=20;
           
        }
        if(isTouching(Virus.class)){
           removeTouching(Virus.class);
           getscore-=100;
           //Bloodstream w = (Bloodstream)getWorld();
           //w.addScore(getscore);
        }
        Bloodstream w = (Bloodstream)getWorld();
        w.addScore(getscore);
    }
    private void checkKeyPress()
    {
        if (Greenfoot.isKeyDown("up")) 
        {
            setLocation(getX(), getY()-4);
        }
        
        if (Greenfoot.isKeyDown("down")) 
        {
            setLocation(getX(), getY()+4);
        }
        
        if (Greenfoot.isKeyDown("left")) 
        {
            setLocation(getX()-4, getY());
        }
        
        if (Greenfoot.isKeyDown("right")) 
        {
            setLocation(getX()+4, getY());
        }
    }
}
